package dhee.wtqshopproject.dao;

import dhee.wtqshopproject.entity.Address;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

@Mapper
public  interface AddressMapper {
    // 根据用户ID查询收货地址
    @Select("SELECT * FROM address WHERE user_id = #{userId}")
    Address selectAddressById(Integer userId);
    //插入

    @Insert("INSERT INTO address (user_id, recipient, phone, province, city, district, detail_address, is_default) " +
            "VALUES (#{userId}, #{recipient}, #{phone}, #{province}, #{city}, #{district}, #{detailAddress}, #{isDefault})")
    @Options(useGeneratedKeys = true, keyProperty = "addressId", keyColumn = "address_id")
    int insertAddress(Address address);
}

